import request from '@/utils/http'
import { BaseResult } from '@/types/axios'
import {
  LoginParams,
  ResetPasswordParams,
  GetCodeParams,
  ChangePasswordParams,
  ChangeHeaderParams
} from './model/loginModel'

export class UserService {
  // 登录
  static login(params: LoginParams) {
    return request.post<BaseResult>({
      url: 'admin/login',
      data: params
    })
  }

  // 重置密码
  static resetPassword(params: ResetPasswordParams) {
    return request.post<BaseResult>({
      url: 'admin/forgetPassword',
      params
    })
  }

  // 退出登录
  static logout() {
    return request.post<BaseResult>({
      url: '/vue-admin-template/user/logout'
    })
  }

  // 获取短信验证码
  static getCode(params: GetCodeParams) {
    return request.post<BaseResult>({
      url: 'admin/getCode',
      params
    })
  }

  // 修改密码
  static changePassword(params: ChangePasswordParams) {
    return request.post<BaseResult>({
      url: '/platform_user/updatePassword',
      params
    })
  }

  // 修改头像
  static changeHeader(params: ChangeHeaderParams) {
    return request.post<BaseResult>({
      url: '/platform_user/updateAvatar',
      params
    })
  }
}
